<?php
/**
 * @author Thibaut Cromphaut, Gaïtano Boeraeve, Mathias Helin, Dimitry Dierickx
 * @copyright  Copyright (c) 2011 Artevelde University College Ghent 
 */

class Application_Form_Element_UserEmail extends Zend_Form_Element
{
    public function init()
    {
        parent::init();
        $this->addDecorator('ViewScript', array(
            'viewScript' => 'user/el_user-email.phtml'
        ));
    }
    
    public function setValue($value)
    {
        if(is_object($value) && get_class($value) == "Application_Model_UserHasEmail")
        {
            $value = $value->toFormValue();
        }
        else
        {
            if(is_array($value))
            {
                @list($id, $email, $type) = $value;			
                $value = $id."*".$email."*".$type;
            }
        }
 
        return parent::setValue($value);
    }
}